//
//  BookTableViewCell.m
//  HelpThePoor
//
//  Created by van7ish on 2016/12/1.
//  Copyright © 2016年 van7ish. All rights reserved.
//

#import "BookTableViewCell.h"

#define cellHeight HeightScale(160)

@implementation BookTableViewCell

- (UIImageView *)coverImageView{
    if (!_coverImageView) {
        _coverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(15), HeightScale(15), (cellHeight - WidthScale(30)) / 1.34, cellHeight - HeightScale(30))];
        _coverImageView.image = ImageNamed(@"1");
    }
    return _coverImageView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.coverImageView.frame) + WidthScale(15), self.coverImageView.frame.origin.y, SCREEN_W - CGRectGetMaxX(self.coverImageView.frame) - WidthScale(30), HeightScale(30))];
        _titleLabel.text = @"环境科学知识";
        _titleLabel.font = FONTSIZE(17);
    }
    return _titleLabel;
}

- (UIImageView *)authorImageView{
    if (!_authorImageView) {
        _authorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, CGRectGetMaxY(self.coverImageView.frame) -   HeightScale(16.25), WidthScale(12.5), HeightScale(12.5))];
        _authorImageView.image = ImageNamed(@"people");
    }
    return _authorImageView;
}

- (UILabel *)authorLabel{
    if (!_authorLabel) {
        _authorLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.authorImageView.frame) + WidthScale(5), CGRectGetMaxY(self.coverImageView.frame) - HeightScale(20), WidthScale(160), HeightScale(20))];
        _authorLabel.text = @"林十之";
        _authorLabel.font = FONTSIZE(13);
        _authorLabel.textColor = COLOR_FONTLIGHTGRAY;
    }
    return _authorLabel;
}

- (UILabel *)descLabel{
    if (!_descLabel) {
        _descLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, CGRectGetMaxY(self.titleLabel.frame), self.titleLabel.frame.size.width, self.coverImageView.frame.size.height - self.titleLabel.frame.size.height - self.authorLabel.frame.size.height)];
        _descLabel.text = @"大幅度咖啡店开了你了发了附近廊坊看联发科的烦恼啊看了非健康的您付款的奶粉里卡订单地方都能发肯定是发你看的烦恼快萨芬。";
        _descLabel.numberOfLines = 0;
        _descLabel.font = FONTSIZE(15);
        _descLabel.textColor = COLOR_FONTLIGHTGRAY;
    }
    return _descLabel;
}

- (UIView *)underLine{
    if (!_underLine) {
        _underLine = [[UIView alloc] initWithFrame:CGRectMake(WidthScale(10), cellHeight - 0.5, SCREEN_W - WidthScale(10) * 2, 0.5)];
        _underLine.backgroundColor = COLOR_GRAYLINE;
    }
    return _underLine;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.contentView.backgroundColor = COLOR_LIGHTBGCOLOR;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView addSubview:self.coverImageView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.descLabel];
    [self.contentView addSubview:self.authorImageView];
    [self.contentView addSubview:self.authorLabel];
    [self.contentView addSubview:self.underLine];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
